﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace TARS.ControlCP
{
    public partial class BranchesInfo : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
                loaddata();
        }
        protected void loaddata()
        {
            using (var db = new TARSDelivery_EprojectEntities())
            {
                var brancheszone = db.t_BrachesZone;
                cbbBranchesZoneID.DataSource = brancheszone.ToList();
                cbbBranchesZoneID.DataTextField = "ZoneName";
                cbbBranchesZoneID.DataValueField = "ID";
                cbbBranchesZoneID.DataBind();
            }
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            using (var db = new TARSDelivery_EprojectEntities())
            { 
                DateTime time =Convert.ToDateTime(DateTime.Now.ToString());
                Guid branchesZone = new Guid(cbbBranchesZoneID.SelectedValue.ToString());
                var insert = db.Insert_BranchesInfo(txtName.Text, txtAddress.Text, txtCity.Text, txtZipCode.Text, txtState.Text,
                    txtPhone1.Text, txtPhone2.Text, time, branchesZone);
            }
        }
    }
}